package com.nchu.commondevelopmentframework.controller;

import com.nchu.commondevelopmentframework.common.domain.ApiResult;
import com.nchu.commondevelopmentframework.converter.RoleConverter;
import com.nchu.commondevelopmentframework.entity.Role;
import com.nchu.commondevelopmentframework.service.RoleService;
import com.nchu.commondevelopmentframework.vo.RoleListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @className: RoleController
 * @description: 角色控制类
 * @author: Li Chuanwei
 * @date: 2024/02/24 20:16
 * @Company: Copyright [日期] by [作者或个人]
 **/
@RestController
@RequestMapping("/role")
public class RoleController {
    @Autowired
    private RoleService<Role> roleService;

    @GetMapping("/getAllRoles")
    public ApiResult<List<RoleListVO>> getMenuByUserId() {
        List<Role> roles = roleService.selectAllRoles();
        List<RoleListVO> roleListVO = RoleConverter.INSTANCE.menusToRoleListVOs(roles);
        return ApiResult.success(roleListVO);
    }
}
